﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DocumentsTagger.UI.ViewModel;

namespace DocumentsTagger.UI.Commands
{
    public class StartScannerCommand:ACommandBase
    {
        private readonly MainWindowViewModel r_vm;

        public StartScannerCommand(MainWindowViewModel vm)
        {
            r_vm = vm;
        }

        /// <summary>
        /// returns the ability to execute the command
        /// </summary>
        /// <param name="parameter">can be null</param>
        /// <returns>true if the command can be executed</returns>
        public override bool CanExecute(object parameter)
        {
            return true;
        }

        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="parameter">boolean, true to start the scanning, false to stop.</param>
        public override void Execute(object parameter)
        {
            bool wasChangedToStart = (bool)parameter;
            if (wasChangedToStart)
            {
                r_vm.StartScanner();
            }
            else
            {
                r_vm.StopScanner();
            }
        }
    }
}
